package com.sinopec.basemodule.base;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

public class PageInfo<T> implements Parcelable {
    private boolean hasNextPage;
    private int total;
    private int pages;
    private List<T> list;

    public PageInfo(){

    }

    protected PageInfo(Parcel in) {
        hasNextPage = in.readByte() != 0;
        total = in.readInt();
        pages = in.readInt();
    }

    public static final Creator<PageInfo> CREATOR = new Creator<PageInfo>() {
        @Override
        public PageInfo createFromParcel(Parcel in) {
            return new PageInfo(in);
        }

        @Override
        public PageInfo[] newArray(int size) {
            return new PageInfo[size];
        }
    };

    public boolean isHasNextPage() {
        return hasNextPage;
    }

    public void setHasNextPage(boolean hasNextPage) {
        this.hasNextPage = hasNextPage;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (hasNextPage ? 1 : 0));
        dest.writeInt(total);
        dest.writeInt(pages);
    }
}
